<!DOCTYPE html>
<html class="um landscape min-width-240px min-width-320px min-width-480px min-width-768px min-width-1024px">
    <head>
        <title></title>
        <meta charset="utf-8">
        <meta name="viewport" content="target-densitydpi=device-dpi, width=device-width, initial-scale=1, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
        <link rel="stylesheet" href="css/fonts/font-awesome.min.css">
        <link rel="stylesheet" href="css/ui-box.css">
        <link rel="stylesheet" href="css/project/ui-base.css">
        <link rel="stylesheet" href="css/ui-color.css">
        <link rel="stylesheet" href="css/appcan.icon.css">
        <link rel="stylesheet" href="css/appcan.control.css">
        
        
        <link rel="stylesheet" href="css/main.css">
        <link rel="stylesheet" href="css/text.css">
        <link rel="stylesheet" href="css/icon.css">
        <link rel="stylesheet" href="css/sign.css">
        <link rel="stylesheet" href="css/staff.css">
        <link rel="stylesheet" href="css/difu.css"/>
        <link rel="stylesheet" href="css/project/style.css">
        <style type="text/css">
            .title{
    display: -webkit-box !important;
    height:2.75em;

    background-color:#3e454f;
    padding:0 0.6em;
    -webkit-box-align:center;
}
.title-left{
    width:3em;  
    background-repeat: no-repeat;
    background-position:  left center;
    height: 1.3em;
}
.title-mid{
    -webkit-box-flex: 1;
    text-align:center;
    color:#fff;
}
.title-right{
    width:3em; 
    background-repeat: no-repeat;
    background-position: right center;
}

[goback]{
    background-image: url("images/img26.png");
    background-size: 2.8em 1.3em;
}
        
        
            .typeCircle {
                width: 1em;
                height: 1em;
                -moz-border-radius: 50%;
                -webkit-border-radius: 50%;
                border-radius: 50%;
            }
            .zw40{
                width: 40%;
            }
            .zformat{white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
            .zct{
                margin: 0 aut0;
            }
            .zbcred{
                background-color: #FF5B58;
            }
            .zbcgreen{
                background-color: #80C468;
            }
            .zleft{background-image: url("images/Arrow-left.png");}
            .zright{background-image: url("images/Arrow-right.png");}
            .zub-img
            {
                -webkit-background-size:contain;
                background-size:contain;
                background-repeat:no-repeat;
            }
            .zimgl{ background-position: left;}
            .zimgr{ background-position: right;}
            .bor{ border:solid 1px #45598C;}
            .bor_r{ border-right:solid 1px #45598C;}
            .b_45598C{background-color:#45598C; }
            .c_45598C{color:#45598C; }
        </style>
    </head>
   <body class="um-vp c-wh" ontouchstart>
        
        <div id="schedule_content" >
            <div>
                 <!-- 页头 -->
                <header id="header" class="header">
                    <div class="title">
                        <div class="title-left" goback onclick="exitApp();"></div>
                        <div class="title-mid" id="title">个人绩效</div>
                        <div class="title-right" openmore></div>
                    </div>  
                </header>
                <!-- 内容 -->
                <!---个人绩效--->
                <div name="toDo">
                    <!---div class="ub bc0097F3 c1 mt10 mb6 lh20 bd_b bd_t">
                            <span class="ml8">个人绩效</span>
                    </div--->
                    <div class="ub ub-ac ml6 fs9 mt10">
                        <div class="ub-f1 "><span class="c25">月工分：</span><span id="totalWeek">-</span></div>
                        <div class="ub-f1"><span class="c25">年工分：</span><span id="totalYear">-</span></div>
                    </div>
                    <div class="ub ub-ac tx-c bor lh16 m8 uc-a3 c_45598C">
                        <div class="ub-f1 bor_r b_45598C c1" tab="week">周</div>
                        <div class="ub-f1 bor_r" tab="month">月</div>
                        <div class="ub-f1" tab="year">年</div>
                    </div>
                    <div id="personalKPI" style="width:100%;height:15em;">
                        
                    </div>
                    <div class="ub ub-ac tx-c lh17 c_45598C" name="buttons">
                        <div class="ub-f1 m5 uc-a3 bor c15" bt="0">绩效方案</div>
                        <div class="ub-f1 m5 uc-a3 bor" bt="1">工分查询</div>
                        <div class="ub-f1 m5 uc-a3 bor c15" bt="2">意见反馈</div>
                    </div>
                </div>
                <div class="ml5 mt10 mb5 fs9">注：统计截止当日前4天。</div>
                
            </div>
        
            
        </div>
    </body>
    <script src="js/zy_control.js"></script>
    <script src="js/zy_click.js"></script>
    <script src="js/zy_jsonModify.js"></script>
    <script src="js/appcan.js"></script>
    <script src="js/appcan.control.js"></script>
    <script src="js/appcan.tab.js"></script>
    <script src="js/jquery-1.11.1.min.js"></script>
    <script src="js/staff.js?v=202022"></script>
    <script src="js/calendar.js?v=202022"></script>
    <script src="js/highcharts.js?v=202022"></script>
    <script src="js/main.js?v=202022"></script>
    <script>
        var calendar;
        var resultList = [];
        
        //年
        var year = getYear();
        //月
        var month = getMonth();
        // month="6"; 
        //年月
        var ymonth = year + '-' + month;
        
        //日历年月
        $("#ymonth").text(year + '-' + month);
        
        appcan.ready(function() {
            exitreturn();
            getTime();
            
            getToDoList();
            noticeList(0,3);
            //获取数据
            // getScheduleList(ymonth);
            
            //绘制日历
            // initView(year, month);
            
            //选择年月
            // appcan.button("#dateTool", "btn-act", function() {
                // var ymonth = $("#ymonth").text().split('-');
                // changeYmonth(ymonth[0], ymonth[1]);
            // });
           
            appcan.button("#applicationBtn ", "ani-act", function() {
                //uexWindow.evaluateScript('today', '0', 'openTab("休息申请","11390838");');
            });
            
            clickHandler();
            getKPIdata(function(json){KPIData(json);});
        });
var KPIjson;
var totalMonth=0;
var totalYear=0;
function KPIData(json)
{
    KPIjson=json;
    localStorage.setItem("KPI_siteName",json.day.siteName);
    localStorage.setItem("KPI_groupName",json.day.groupName);
    localStorage.setItem("KPI_empNo",json.day.empNo);
    var leny=KPIjson.year.length;
   
    for(var y=0;y<leny;y++)
    {
        totalYear+=parseFloat(KPIjson.year[y].workpoints);
        if(DATE.split("-")[1]=KPIjson.year[y].dataTime){
            totalMonth=KPIjson.year[y].workpoints;
        }
    }
    $("#totalWeek").text(totalMonth);
    $("#totalYear").text(totalYear);
    // console.log("KPIData--"+JSON.stringify(json));
    hatchChart("week");
}        
function clickHandler(){
    $("[tab]").click(function(){
                  $("[tab]").removeClass("b_45598C c1");
                  $(this).addClass("b_45598C c1");
                  var tb=$(this).attr("tab");
                  // alert(tb)
                  hatchChart(tb);
         });
  $("[bt]").click(function(){
          var bt=$(this).attr("bt");
          switch(bt)
          {
              case '0':
                    
              break;
              case '1':
                appcan.window.open({
                    name:'pointQuery',
                    dataType:0,
                    data:'pointQuery.html'
                 });
              break;
              case '2':
                  /*appcan.window.open({
                        name:'feedback',
                        dataType:0,
                        data:'feedback.html'
                     });*/
              break;
          }
     });
}
function hatchChart(tb) {
    // alert(JSON.stringify(KPIjson));
    console.log(KPIjson)
    var categoriesArr=[];
    var dataArr=[];
    $('#personalKPI').html("<div class='tx-c'><br/>暂无数据!</div>");
  switch(tb)
  {
      case "week":
        var lenw=KPIjson.week.length;
        // alert(lenw)
        // var tmp=KPIjson.week[0].dataTime;
         var tmp=GetDateStr(-4);
          // alert(tmp)
        // console.log(KPIjson.week)
        var tmpY=tmp.split("-")[0];
        var tmpM=tmp.split("-")[1];
        var tmpD=tmp.split("-")[2];
        for(var k=0;k<7;k++)
        {
            categoriesArr[k]=tmpM+"-"+tmpD;
            dataArr[k]=0;
            var dates=tmpY+"-"+tmpM+"-"+tmpD;
            for(var w=0;w<lenw;w++)
            {
                 if(dates==KPIjson.week[w].dataTime)
                 {
                    dataArr[k]=parseFloat(KPIjson.week[w].workpoints);
                 }
            }
            tmpD=parseFloat(tmpD);
            tmpD--;
            if(tmpD<10)
            {
                tmpD="0"+tmpD;
            }
        }
        categoriesArr.reverse();
        dataArr.reverse();
        // console.log(dataArr);
      break;
      case "month":
        categoriesArr=['第1周','第2周','第3周','第4周'];
        for(var m=3;m>=0;m--)
        {
          dataArr[m]=parseFloat(KPIjson.month[3-m].workpoints);
        }
        // console.log(dataArr);
        // dataArr=[794,744,690,518]
      break;
      case "year":
      categoriesArr= ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月','11月', '12月']
      var leny=KPIjson.year.length;
      for(var y=0;y<12;y++){
          dataArr[y]=0;
          for(var n=0;n<leny;n++)
          {
              if(KPIjson.year[n].dataTime==y){
                  dataArr[y-1]=parseFloat(KPIjson.year[n].workpoints);
              }
          }
      }
      // dataArr=[ 0, 0, 0, 0, 0, 0, 0, 3755, 2746, 0, 0, 0];
      break;
  }
  $('#personalKPI').empty();
  $('#personalKPI').highcharts({ 
       chart: { 
            renderTo: 'chart_line', //图表放置的容器，DIV 
            defaultSeriesType: 'line', //图表类型line(折线图), 
            zoomType: 'x'   //x轴方向可以缩放 
        }, 
        credits: { 
            enabled: false   //右下角不显示LOGO 
        }, 
        title: { 
            text: '' //图表标题 
        }, 
        xAxis: {  //x轴 
            categories: categoriesArr, //x轴标签名称 
            lineWidth: 1,  //基线宽度 
        }, 
        yAxis: {  //y轴 
            title: '', //标题 
            lineWidth: 1 //基线宽度 
        }, 
        
        legend: {  //图例 
            enabled: false  //设置图例不可见 
        }, 
        exporting: { 
            enabled: false  //设置导出按钮不可用 
        }, 
        series: [{  //数据列 
            name: '工分', 
            data:dataArr 
        }] 
    });
}
 Highcharts.setOptions({
                colors: ['#00FF41']
}); 
function changeDate (direction) {
           var ymonth = '';
           var date=$("#ymonth").text();
           var dateArr=date.split("-");
           var y = dateArr[0];
           var m = dateArr[1];
           switch(direction)
          {
              case "left":
                    m--;
                    if(m<1)
                    {
                       m=12;
                       y--; 
                    }
              break;
              case "right":
                    m++;
                    if(m>12)
                    {
                       m=1;
                       y++; 
                    }
              break;
          }
        if(m < 10){
            m =  '0' +m;
        }
        ymonth = y + '-' +m;
        $("#ymonth").text(ymonth);
        getScheduleList();
        // initView(y, m);  
}
        

        //获取数据
        function getScheduleList() {
            var date=$("#ymonth").text();
            var dateArr=date.split("-");
            var y = dateArr[0];
            var m = dateArr[1];
            var SiteName='PVGHCC';//站点名称
            var SiteID='0';//SiteID
            var EmployeeNumber='35010314';//员工工号
            var PeriodStart= y+'-'+m+'-'+'01';//开始日期
            var PeriodEnd=y+'-'+m+'-'+getDaysInMonth(y,m);//结束日期
            var wsdl = scheduling_url; 
            var nameSpace = scheduling_nameSpace;
            var paras = "CenterName|SiteID|StartDate|EmployeeNumber|EndDate";
            var values = SiteName+'|'+SiteID+'|'+PeriodStart+'|'+EmployeeNumber+'|'+PeriodEnd;
            var method = scheduling_function
            setLocalJosn(wsdl,nameSpace,paras,values,method)
        }
        
        //绘制日历
        function initView(year, month) {
            
            calendar = calUtil.drawCal(year, month, resultList, -1);
            $("#calendar").html(calendar);

           /* appcan.button(".item", "", function() {
                var week = $(this).parent().attr("week");
                appcan.locStorage.setVal("week", week);
                //$("#schedule_content").load("schedule_detail.html");
                
                window.location.href = "schedule_detail.html";
            });*/
        }

        //选择年月
        function changeYmonth(year, month){

            uexControl.openDatePickerWithoutDay(year, month);
            uexControl.cbOpenDatePickerWithoutDay = function(opId, dataType, data) {
                
                var ymonth = '';
                data = eval("("+data+")");
                
                var y = data.year;
                var m = data.month;
                
                if(m < 10){
                    ymonth = y + '-0' +m;
                }else{
                    ymonth = y + '-' +m;
                }
                $("#ymonth").text(ymonth);
                
                //获取数据
                getConfigList(ymonth);
            }
        }
        
function noticeList(startPage,pageNum){
    var wsdl = business_list_url
    var nameSpace = business_list_nameSpace;
    var paras = "startPage|pageNum";
    var values =startPage + '|' + pageNum;
    var method = business_list_function;
    currentJosn(wsdl,nameSpace,paras,values,method);    
}
function returnjson(currentJosnStr){
   getScheduleList(); //先业务资料数据后再获取获取排版数据
    // console.log(currentJosnStr)
    var  obj = currentJosnStr;
    obj = strToJson(obj);
    var objdata = obj[0].data;   
    var strx='';
    
    for(var i=0;i<3;i++)   
    {   
        var PublicTime = objdata[i].PublicTime;
        var a = PublicTime.split(" ");
        PublicTime = a[0];
        
        var time = PublicTime.split("/");
        var year=time[0].substr(2,2)
        var month=time[1]
        if(month<10)
        {
            month=0+''+month
        }
        var date=time[2]
        if(date<10)
        {
            date=0+''+date
        }
        PublicTime=year+'/'+month+'/'+date;
        
        strx+='<div class="ub bd_b lh13 mt3 mb4 fs9 ml8 pb5" onclick="moreNotice()">\
                    <div class="ub-f3 w100">\
                        <div class="c0 zformat">'+objdata[i].Title+'</div>\
                    </div>\
                    <div class="ub ub-f1 c25 w20 tx-r">'+PublicTime+'</div>\
                </div>';
    }
    strx+='<div class="lh13 mt3 mb15 fs8 mr18 tx-r c0097F3" ><span onclick="moreNotice()">查看更多...</span><br><div class"lh20">&nbsp;</div></div>';
    $("#noticeList").html(strx);
}  

function calendarjson (json) {
     
    // console.log(json)
    var  objArr = json.DataTable;
    var len=objArr.length;
    var scheduleArr='';
    for(var i=0;i<len;i++)
    {
        var dateId=objArr[i].dateId;
        var date=dateId.substr(8,2);
        // resultList.push(parseInt(date));
        scheduleArr+=parseInt(date)+'/';
    }
    scheduleArr=scheduleArr.substr(0,scheduleArr.length-1);
    localStorage.setItem("scheduleDate",scheduleArr);
    //绘制日历
    var date=$("#ymonth").text();
            var dateArr=date.split("-");
            var y = dateArr[0];
            var m = dateArr[1];
            initView(y, m);
}

//返回主页面
function exitApp(){
    
//  localStorage.setItem("ZV_EMPLOYEE_NUMBER","");
//  localStorage.setItem("ZV_Account","");
//  localStorage.setItem("ZV_UserName","");
//  localStorage.setItem("ZV_Department","");
    localStorage.setItem("fly_zv_carrier","");
    localStorage.setItem("fly_zv_flightNo","");
    localStorage.setItem("fly_zv_pdate","");
    localStorage.setItem("fly_zv_dept","");
    localStorage.setItem("fly_zv_arr","");
    localStorage.setItem("fly_zv_choose","");
    //uexWindow.close(-1);
    uexWidget.finishWidget('');
}
    </script>
</html>
